import turtle

def draw_trajectory(x_max, y_max):
    screen = turtle.Screen()
    screen.setup(width=800, height=600)
    screen.title("Turtle Trajectory")

    turtle.speed(2)  # 初始速度，可以根据需要调整

    current_x, current_y = 0, 0

    for y in range(y_max + 1):
        # Draw a row from left to right
        for x in range(x_max + 1):
            turtle.goto(x, y)
            turtle.dot(20)  # 绘制一个点，代表每一步
            print(f"({x},{y})")
            current_x, current_y = x, y

        # Draw a row from right to left for odd rows
        if y % 2 == 1:
            for x in range(x_max, -1, -1):
                turtle.goto(x, y)
                turtle.dot(20)
                print(f"({x},{y})")
                current_x, current_y = x, y

    turtle.done()

# 获取用户输入
x_max = int(input("请输入X方向的最大值（正整数）："))
y_max = int(input("请输入Y方向的最大值（正整数）："))

# 绘制轨迹
draw_trajectory(x_max, y_max)
